package com.cvicse.crud.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cvicse.crud.dao.EmployeeMapper;
import com.cvicse.crud.entity.Employee;

@Service
public class EmployeeService {
	
	@Autowired
	EmployeeMapper employeeMapper;
	
	//查询所有员工信息
	public List<Employee> getAll() {
		return employeeMapper.selectByExampleWithDept(null);
	}
	//保存新增的员工信息
	public void saveEmp(Employee employee) {
		employeeMapper.insertSelective(employee);
	}
	//按照员工id查询员工信息
	public Employee getEmp(Integer id) {
		Employee employee = employeeMapper.selectByPrimaryKey(id);
		return employee;
	}
	//更新员工信息(更新部分信息)
	public void updateEmp(Employee employee) {
		employeeMapper.updateByPrimaryKeySelective(employee);
	}
	public void deleteEmp(Integer id) {
		employeeMapper.deleteByPrimaryKey(id);
	}
	
}
